Spatial analysis from ESM 244 at UCSB.
The data used in this report includes locations of oil spills in California in 2008 as well as California county boundaries, which are merged together. Here I first look at where all of the 2008 oil spills were in California in an exploratory interactive visualization. Then, I construct a static choropleth map that shows which counties had the most oil spills in 2008.
Oil spill data from CA DFW Oil Spill Incident Tracking, 2008. https://gis.data.ca.gov/datasets/7464e3d6f4924b50ad06e5a553d71086_0/data Shapefile data for the borders of California counties from the U.S. Census Bureau. https://data.ca.gov/dataset/ca-geographic-boundaries
# Read in the data
# County shapes for CA
ca_counties_sf <- read_sf(here("data", "CA_Counties_TIGER2016.shp")) %>%
clean_names()
# Oil spill events
oil_sf <- read_sf(here("data", "ds394.shp")) %>%
clean_names()
# Select only county names (for combining with oil spill dataset later)
ca_subset_sf <- ca_counties_sf %>%
select(county_name = name)
# Check counties CRS
#ca_subset_sf %>% st_crs()
# Change the oil spill CRS to match counties CRS
oil_3857_sf <- st_transform(oil_sf, st_crs(ca_counties_sf))
# Then check oil spill CRS to make sure it now matches
#oil_3857_sf %>% st_crs()
# Set the viewing mode to "interactive"
tmap_mode(mode = "view")
# Make a map with county outlines, then add another shape layer for the oil spill records (added as dots)
tm_shape(ca_subset_sf) +
tm_borders(lwd = 1,
col = "grey") +
tm_shape(oil_3857_sf) +
tm_dots(col="red2")